package IO流.标准输出流.日志工具.Test01;

import javax.xml.crypto.Data;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LogUtil {
    public static void log(String msg) {
        PrintStream out = null;
        try {
            out = new PrintStream(new FileOutputStream("javase/src/IO流/标准输出流/日志工具/Test01/演示文件.txt",true));
            out.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        System.setOut(out);
        Date nowTime = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd- HH:mm:ss SSS");
        String strTime = sdf.format(nowTime);
        System.out.println(strTime + ": " + msg);
    }
}
